
import axios from 'axios';
import Ajax from '../../core/Ajax';
export default class ShanbayUrl {
    public async GetWordId(token, word): Promise<string> {
        if (!word) {
            throw "单词为空";
        }
        const url = `https://api.shanbay.com/bdc/search/?access_token=${token}&word=${word}`;

        const ret = (await axios.get(url)).data;

        if (ret.status_code == 0) {
            return ret.data.id;
        }

        throw ret.msg;
    }
    public async Post(token, id): Promise<boolean> {
        if (!id) {
            throw "单词为空";
        }
        const url = `https://api.shanbay.com/bdc/learning/?access_token=${token}`;
        const ret = (await Ajax.post(url, { id: id }));
        if (ret.status_code == 0) {
            return true;
        }

        throw ret;
    }
}